{extend name="Administrator/nav"}
{block name="title"}班级管理{/block}
{block name="content"}
<div class="row">
    <div class="col-md-12">
        <div class="container">
            <div class="row">
                <div class="col-md-8">
                    <form class="form-inline" action="{:url()}">
                        <div class="form-group">
                            <label class="sr-only" for="name">班级管理</label>
                            <input name="name" type="text" class="form-control" placeholder="请输入要搜索的关键字..."value="{:input('get.name')}">
                        </div>
                        <button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i>&nbsp;查询
                        </button>
                    </form>
                </div>
                <div class="col-md-4 text-right">
                    <button class="btn btn-primary" data-toggle="modal" data-target="#mymodal-data"><i
                            class="glyphicon glyphicon-plus"></i>&nbsp;增加
                    </button>
                    <div class="modal bs-example-modal-lg" id="mymodal-data" tabindex="-1" role="dialog"
                         aria-labelledby="mySmallModalLabel" aria-hidden="true">
                        <div class="modal-dialog  modal-lg">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                                            class="sr-only">Close</span></button>
                                    <h4 class="modal-title text-left">增加班级</h4>
                                </div>
                                <div class="modal-body text-left">

                                    <form action="{:url('insert')}" method="post">
                                        <br>
                                        <div class="col-md-3 row">
                                            <label class="col-md-4 select_label">学院</label>
                                            <div class="col-md-8">
                                                <select id="college" class="form-control" onchange="yunzhi.getMajor('college', 'major', 'grade')">
                                                    {volist name="colleges" id = "College"}
                                                    <option value="{$College->id}">
                                                        {$College->name}
                                                    </option>
                                                    {/volist}
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-md-3 row">
                                            <label class="col-md-4 select_label">专业</label>
                                            <div class="col-md-8">
                                                <select id="major" class="form-control" onchange="yunzhi.getGrade('major', 'grade', 'klass')">
                                                    <option>
                                                    </option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="col-md-3 row">
                                            <label class="col-md-4 select_label">年级</label>
                                            <div class="col-md-8">
                                                <select id="grade" class="form-control" onchange="yunzhi.getKlassId('grade')">
                                                    <option>
                                                    </option>
                                                </select>
                                            </div>
                                        </div>
                                        <label>班级名称：</label>

                                        <input type="text" name="name">
                                        <button type="submit" class="btn btn-primary">保存</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <br><br>
            <form action="{:url('index')}" method="post" class="form-inline">
                <div class="row">
                    <div class="col-md-3">
                        <label>学院:</label>

                        <select class="btn btn-default dropdown-toggle" name="searchCollegeId" id="searchCollege" onchange="yunzhi.getMajor('searchCollege', 'searchMajor', 'searchGrade')">

                            {volist name="colleges" id="College"}
                            <option value="{$College->id}" {eq name="$College->id" value="searchCollegeId"} selected="selected"{/eq}>{$College->name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="col-md-3">
                        <label>专业：</label>

                        <select class="btn btn-default dropdown-toggle" name="searchMajor" id="searchMajor" onchange="yunzhi.getGrade('searchMajor', 'searchGrade')">
                            <option></option>

                        </select>
                    </div>
                    <div class="col-md-3">
                        <label>年级：</label>

                        <select class="btn btn-default dropdown-toggle" name="searchGradeId" id="searchGrade"
                               onchange="yunzhi.getKlassId('searchGrade')">

                            <option></option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <button type="submit" class="btn btn-default">搜索</button>
                    </div>
                </div>
            </form>

            <hr/>
            <table class="table table-hover table-bordered">
                <tr class="info">
                    <th width="10%">ID</th>
                    <th width="70%">班级名称</th>
                    <th width="20%">操作</th>
                </tr>
                {volist name="klasses" id="_Klass" key="key"}
                <tr>
                    <td>{$key}</td>
                    <td>{$_Klass->getData('name')}</td>
                    <td>
                        <button class="btn btn-sm btn-primary" data-toggle="modal" data-target="#editKlass{$key}"><i class="glyphicon glyphicon-pencil"></i>&nbsp;编辑</button>
                        <a class="btn btn-sm btn-danger" href="{:url('delete?id=' . $_Klass->getData('id'))}"><i
                                class="glyphicon glyphicon-trash"></i>&nbsp;删除</a>

                        <div class="modal" id="editKlass{$key}" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"></span></button>
                                        <h4 class="modal-title">编辑班级</h4>
                                    </div>
                                    <div class="modal-body">
                                        <form action="{:url('update')}" method="post">
                                            <label>班级名称：</label>
                                            <input type="hidden" name="id" value="{$_Klass->getData('id')}"/>
                                            <input type="text" name="name" id="name" value="{$_Klass->getData('name')}">
                                            <button type="submit" class="btn btn-primary">保存</button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
                {/volist}
            </table>
            {:$klasses->render()}
        </div>
    </div>
</div>
<script type="text/javascript" src="/labManageSystem/public/login/studentRegister.js"></script>

<script>

    var searchCollegeId = {$searchCollegeId};
    var searchMajorId = {$searchMajorId};
    var searchGradeId = {$searchGradeId};
    // yunzhi.getMajor('college', 'major', 'grade');
    yunzhi.getMajor('searchCollege', 'searchMajor', 'searchGrade', 0, searchCollegeId, searchMajorId, searchGradeId);
</script>
{/block}